package com.thd.kc.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.thd.kc.utils.ListUtils;
import com.thd.kc.utils.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class ArticleDto {
    private String id;
    private String title;
    private String keywords;
    private String classify;
    @JsonIgnore
    private String tags;
    private String content;
    private String createTime;
    private String modifyTime;
    // 检索关键字，包括title keywords content
    private String kw;

    private Integer total = 0;
    private Integer currentPage = 0;
    private Integer pageSize = 5;
    private String searchTags ;

    private List<String> tagsList;

    // 查询类型  DB:数据库查询  LUCENE:Lucene查询
    private String queryType ;

    // 分词之间的查询关系 true: and   false:or
    private Boolean logicalSplitWord = true;


    public List<String> getTagsList(){
        return this.tagsList;
    }

    public void setTagsList(List<String> tagsList){
        this.tagsList = tagsList;
        if(ListUtils.isNotEmpty(tagsList)){
            this.tags = tagsList.stream().collect(Collectors.joining(","));
        }else{
            this.tags = "";
        }
    }

    public void setTags(String tags) {
        this.tags = tags;
        if(StringUtils.isNotEmpty(tags)){
            this.tagsList = Arrays.asList(tags.split(","));
        }else{
            this.tagsList = new ArrayList<String>();
        }
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getKeywords() {
        return keywords;
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }

    public String getClassify() {
        return classify;
    }

    public void setClassify(String classify) {
        this.classify = classify;
    }

    public String getTags() {
        return tags;
    }



    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(String modifyTime) {
        this.modifyTime = modifyTime;
    }

    public String getKw() {
        return kw;
    }

    public void setKw(String kw) {
        this.kw = kw;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public String getSearchTags() {
        return searchTags;
    }

    public void setSearchTags(String searchTags) {
        this.searchTags = searchTags;
    }

    public String getQueryType() {
        return queryType;
    }

    public void setQueryType(String queryType) {
        this.queryType = queryType;
    }

    public Boolean getLogicalSplitWord() {
        return logicalSplitWord;
    }

    public void setLogicalSplitWord(Boolean logicalSplitWord) {
        this.logicalSplitWord = logicalSplitWord;
    }
}
